package com.jingtai.platform.controller.shop;

import com.jingtai.core.entity.BaseEntity;
import com.jingtai.core.entity.shop.MerchantsGoods;
import com.jingtai.platform.service.shop.MerchantsGoodsService;
import com.jingtai.platform.util.ResultUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.jingtai.validate.swagger.CApiParam;

/**
 * 商户商品表
 *
 * @author sunlaiqian
 * @date 2020-12-02 18:31:32
 */
@Validated
@RestController
@RequestMapping("/platform/merchantsgoods")
@Api(tags = "商户商品表")
public class MerchantsGoodsController{

    @Autowired
    private MerchantsGoodsService merchantsGoodsService;


    @ApiOperation("商户商品表列表查询")
    @GetMapping("/list")
    public ResultUtil aopMerchantsGoodsList(@CApiParam(name = "page",value = "页数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("page") Integer page,
                              @CApiParam(name = "limit",value = "每页个数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("limit") Integer limit,
                              @CApiParam(name = "conditions",value = "查询条件",required = false) @RequestParam("conditions") String conditions){
        return merchantsGoodsService.MerchantsGoodslist(page, limit, conditions);
    }


    @ApiOperation("根据ID查询merchantsGoods实体")
    @GetMapping("/getMerchantsGoodsById")
    public ResultUtil GetMerchantsGoodsById(@CApiParam(name = "id",value = "merchantsGoods实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return merchantsGoodsService.getMerchantsGoodsById(id);
    }

    @ApiOperation("根据GoodsCode新增merchantsGoods实体")
    @GetMapping("/addMerchantsGoodsByGoodsCode")
    public ResultUtil aopAddMerchantsGoodsByGoodsCode(@CApiParam(name = "goodsCode",value = "商品编号",required = true,cNotEmpty = true) @RequestParam("goodsCode") String goodsCode,
                                                      @CApiParam(name = "merchantsId",value = "商户ID",required = true,cNotEmpty = true) @RequestParam("merchantsId") Long merchantsId){
        return merchantsGoodsService.addMerchantsGoodsByGoodsCode(goodsCode,merchantsId);
    }

    @ApiOperation("新增merchantsGoods实体")
    @PostMapping("/add")
    @ApiOperationSupport(ignoreParameters = {"merchantsGoods.id","merchantsGoods.createTime","merchantsGoods.updateTime","merchantsGoods.deleteFlag"})
    public ResultUtil aopAddMerchantsGoods(@RequestBody @Validated({BaseEntity.Create.class}) MerchantsGoods merchantsGoods){
        return merchantsGoodsService.addMerchantsGoods(merchantsGoods);
    }

    @ApiOperation("编辑merchantsGoods实体")
    @PostMapping("/edit")
    @ApiOperationSupport(ignoreParameters = {"merchantsGoods.createTime","merchantsGoods.updateTime","merchantsGoods.deleteFlag"})
    public ResultUtil aopEditMerchantsGoods(@RequestBody @Validated({BaseEntity.Update.class}) MerchantsGoods merchantsGoods){
        return merchantsGoodsService.editMerchantsGoods(merchantsGoods);
    }

    @ApiOperation("根据ID删除merchantsGoods实体")
    @GetMapping("/delMerchantsGoodsById")
    public ResultUtil aopDelMerchantsGoodsById(@CApiParam(name = "id",value = "merchantsGoods实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return merchantsGoodsService.delMerchantsGoodsById(id);
    }


    @ApiOperation("刷新列表")
    @GetMapping("/refreshGoodsListByGoodsCode")
    public ResultUtil aopRefreshGoodsListByGoodsCode(@CApiParam(name = "goodsCode",value = "商品编码",required = true,cNotEmpty = true) @RequestParam("goodsCode") String goodsCode){
        return merchantsGoodsService.refreshGoodsListByGoodsCode(goodsCode);
    }

}






